<template>
  <view>
    <!-- <view class="w100 rowsb rowsm pl-24 pr-24 mb-24">
      <view class="w-352 h-82 br-10 rowsc rowsm fs-30" :style="active == 0 ? 'background-color: #F7F6FA;color:#4878FF;font-weight: bold;' : 'background-color: #fff;color:#888;'" @click="active = 0,getList()">驳回</view>
      <view class="w-352 h-82 br-10 rowsc rowsm fs-30" :style="active == 1 ? 'background-color: #F7F6FA;color:#4878FF;font-weight: bold;' : 'background-color: #fff;color:#888;'" @click="active = 1,getList()">督促</view>
    </view> -->
    
    <view class="w100 pl-24 pr-24" v-if="active == 0">
      <view class="w100 p-all-30 br-10 rowsb rowsm mb-20" style="background-color: #F7F6FA;" v-for="(item,index) in list" :key="index" @click="toPage(item)">
        <view class="rowscl">
          <view class="fs-28 col333 fw-b mb-20">{{item.name}}</view>
          <view class="fs-24 col888">{{item.createTime}}</view>
        </view>
        <view class="w-126 h-50 rowsc rowsm fs-24 br-25" style="border: 2rpx solid #FF6560;color: #FF6560;">已驳回</view>
      </view>
    </view>
    
    <view class="w100 pl-24 pr-24" v-if="active == 1">
      <view class="w100 p-all-30 br-10 rowscl mb-20" style="background-color: #F7F6FA;" v-for="(item,index) in list2" :key="index">
        <view class="w100 rowsb rowsm">
          <view class="fs-28 col333 fw-b mb-20">{{item.title || ''}}</view>
          <view class="w-126 h-50 rowsc rowsm fs-24 br-25" style="border: 2rpx solid #FF6560;color: #FF6560;" v-if="item.subStatus == 1" @click="confirm(item.id)">确认</view>
          <view class="w-126 h-50 rowsc rowsm fs-24 br-25" style="border: 2rpx solid #666;color: #666;" v-else>已确认</view>
        </view>
        <view class="w100 rowsb rowsm">
          <view class="fs-24 col888">{{item.content}}</view>
          <view class="fs-24 col888">{{item.createTime}}</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        active:1,
        list:[],
        list2:[],
        total:0,
        limit: {
          pageNum: 1,
          pageSize: 10
        },
      };
    },
    onLoad() {
      this.getList()
    },
     onReachBottom() {
      if (this.list2.length < this.total) {
        this.limit.pageNum++;
        this.getList()
      }
    },
    onPullDownRefresh() {
      this.limit.pageNum = 1
      this.getList()
    },
    methods:{
      toPage(item){
        uni.navigateTo({
          url:'/pages/msg/toDoListDetail'
        })
      },
      confirm(id){
        this.$tools.axiosFromToken('POST','prouserdc/subDc',{id},'加载中').then(res => {
          this.$tools.showtt(res.msg)
          if(res.code != 200) return
          setTimeout(() => {
            this.getList()
          },1000)
        })
      },
      getList(){
        if(this.active == 0) {
          this.$tools.axiosFromToken('POST','prold/listReject',{},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            let {rows} = res
            this.list = rows
          })
        }
        
        if(this.active == 1) {
          this.$tools.axiosFromToken('POST',`prouserdc/list?pageNum=${this.limit.pageNum}&pageSize=${this.limit.pageSize}`,{},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            // let {rows} = res
            // this.list2 = rows
             this.total = res.total
            if (this.limit.pageNum == 1) {
              this.list2 = res.rows;
            } else {
              this.list2 = [...this.list2, ...res.rows];
            }
          })
        }
      }
    }
  }
</script>

<style lang="scss">
page {
  background-color: #fff;
}
</style>
